<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <main id="app">
        <input v-hkf>
        <input v-hkf="name">
        <p v-hkf></p>
    </main>
</body>
<script src="../vue.min.js"></script>
<script>
    // 注册一个全局自定义指令 `v-hkf`
    Vue.directive("hkf", {
        bind: function(el,{value = "奉先"}) {
            if (el.nodeName == "INPUT") {
                el.value = value
            } else {
                el.innerText = value;
            }
            console.log("bind:",);
        },
        // 当被绑定的元素插入到 DOM 中时……
        inserted: function (el) {
            console.log("inserted:",el);
            // 聚焦元素
            el.focus();
        }
    })

    new Vue({
        el: "#app",
        data() {
            return {
                name: "Hydra"
            }
        }
    })
</script>

</html>